<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!--使用JSP page指令引入类， *为通配符，表示包下面所有的类  -->
<%@page import="com.sample.jdbc.JdbcUtils"%>
<%@page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>show user</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<%--显示用户记录代码实现 --%>

	<form action="<%=path%>/page/user_list.jsp" method="post" name="form1">

		<table width="400" border="1">

			<tr>

				<td align="center">序号</td>

				<td align="center">用户名</td>

				<td align="center">密码</td>
				
				<td align="center">姓名</td>

				<td align="center">操作1</td>

                <td align="center">操作2</td>
			</tr>
			<%
   try{
   //调用JdbcUtils组件方法获得数据库连接
   JdbcUtils jdbcUtils=new JdbcUtils();
   
   Connection conn=jdbcUtils.getConn();
   
   //由conn对象实例创建发送SQL指令给数据库的Statement类型的对象 stmt
   Statement stmt= conn.createStatement();
   
   //定义SQL语句
   String sql="select * from t_user";
   
   //使用stmt executeQuery()方法执行sql语句
   ResultSet rs = stmt.executeQuery(sql);
   

   while (rs.next()){
     String uid=rs.getString("id");
     String userid=rs.getString("userid");
     String pwd=rs.getString("pwd"); 
     String fullname=rs.getString("fullname");
     
     %>
			<tr>
				<td align="center"><%=uid %></td>
				<td align="center"><%=userid %></td>
				<td align="center"><%=pwd %></td>
				<td align="center"><%=fullname %></td>
				<td align="center"><a
					href="<%=path%>/page/user_del_Action.jsp?id=<%=uid %>">删除</a></td>
					<td align="center"><a
					href="<%=path%>/page/user_edit.jsp?id=<%=uid %>&userid=<%=userid%>&pwd=<%=pwd%>&fullname=<%=fullname%>">修改</a></td>
			</tr>
			<%   
      }
   }catch(Exception e){
   
     e.printStackTrace();
   
   }
   
    %>
		</table>
	</form>
</body>
</html>
